home *** CD-ROM | disk | FTP | other *** search
- using System;
- using System.Web;
- using System.Web.UI;
- using GBPVR.Public;
- using GBPVRSchedule;
-
- namespace gbweb
- {
- public partial class ManualRecord2 : Page
- {
- private Settings guideParams;
-
- protected void Page_Load(object sender, EventArgs e)
- {
- getTheme();
-
- if (!IsPostBack)
- {
- //Load the settings from the config file
- guideParams = Global.Settings;
-
- //Fill the drop down list of channels
- Global.FillChannelList(listChannels);
-
- //Set the default name for the recording...display class will provide "Manual Recording"
- //if this feild remains null
- pgmName.Text = null;
-
- //Set the default recording Quality
- quality.SelectedValue = guideParams.recordingQuality;
-
- //Default the start date to today
- startDate.SelectedDate = DateTime.Now;
-
- //Default the start time to now
- startTime.SelectedTime = DateTime.Now;
-
- //Default the stop time to 1 hour from the start time
- endTime.SelectedTime = DateTime.Now.AddHours(1);
-
- //Ensure the error message box is not displaying
- ERROR_MESSAGE.Visible = false;
- }
-
- }
- protected void LinkButton1_Click(object sender, EventArgs e)
- {
- bool scheduleReturn = true;
-
- //Create a Programme
- Programme dummyPgm = new Programme();
-
- //Set the channel that is to be recorded
- dummyPgm.setChannelOID(Convert.ToInt32(listChannels.SelectedValue));
-
- //Set the start time for for programme to record
- string sDate = startDate.SelectedDate.ToShortDateString();
- string sTime = startTime.SelectedTime.ToShortTimeString();
- DateTime fullStartDate = Convert.ToDateTime(sDate + " " + sTime);
- dummyPgm.setStartTime(fullStartDate);
-
- //Set the end time for the programme to record
- string eDate = startDate.SelectedDate.ToShortDateString();
- string eTime = endTime.SelectedTime.ToShortTimeString();
- DateTime fullEndDate = Convert.ToDateTime(eDate + " " + eTime);
-
- //Update the end date if the recording spans two different dates
- if (fullEndDate.Hour < fullStartDate.Hour)
- {
- fullEndDate = fullEndDate.AddDays(1);
- }
- dummyPgm.setEndTime(fullEndDate);
-
- if (pgmName.Text.Length > 0)
- {
- dummyPgm.setTitle(pgmName.Text);
- }
-
- Schedule.Quality quality = 0;
- int prePad = Convert.ToInt32(prePadding.Text);
- int postPad = Convert.ToInt32(postPadding.Text);
- switch (Request.Params["quality"].ToLower())
- {
- case "high":
- quality = Schedule.Quality.High;
- break;
-
- case "medium":
- quality = Schedule.Quality.Medium;
- break;
-
- case "low":
- quality = Schedule.Quality.Low;
- break;
-
- case "custom1":
- quality = Schedule.Quality.Custom1;
- break;
-
- case "custom2":
- quality = Schedule.Quality.Custom2;
- break;
- }
-
- if (radioDay.SelectedValue == "once")
- {
- // schedule one-off recording
- Schedule myschedule = Global.Schedule;
- scheduleReturn = myschedule.ScheduleOnce(dummyPgm, quality, prePad, postPad);
- }
- else
- {
- //Schedule Season Recordings
- //Set the max number of recordings to keep for the show
- int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
- if (keepRecordings.Text.ToString() != null)
- {
- try
- {
- keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
- }
- catch
- {
- keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
- }
- }
- else
- {
- keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
- }
-
- Schedule myschedule = Global.Schedule;
-
- // schedule manual recording for every day of the week
- if (radioDay.SelectedValue == "everyDay")
- {
- scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Daily, prePad, postPad);
- }
- // schedule manual recording for this day on each week
- else if (radioDay.SelectedValue == "everyWeek")
- {
- scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Weekly, prePad, postPad);
- }
- // schedule manual recording for weekdays
- else if (radioDay.SelectedValue == "weekDays")
- {
- scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekDays, prePad, postPad);
- }
- // schedule manual recording for weekends
- else if (radioDay.SelectedValue == "weekEnd")
- {
- scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekEnds, prePad, postPad);
- }
- }
-
- //Display error message if recording does not schedule
- if (scheduleReturn)
- {
- // close popup details window
- ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>reloadAndClose();</script>", false);
- }
- else
- {
- RecordMessage.Text = "Recording Failed!";
- ERROR_MESSAGE.Visible = true;
- }
- }
-
- private void getTheme()
- {
- string theme = Convert.ToString(Session["theme"]);
-
- if (theme != null && theme != "")
- {
- return;
- }
- else
- {
- HttpCookie cookie = Request.Cookies["theme"];
- if (cookie != null && cookie.Value.Length > 0)
- {
- theme = cookie.Value;
- }
- else
- {
- theme = "Default";
- }
- Session["theme"] = "themes/" + theme;
- return;
- }
- }
- }
- }
-